/*
 * Copyright (c) 2017 - 2019, AEye, Inc.
 * All rights reserved.
 */
#ifndef HAWKEYEFRAME_HPP
#define HAWKEYEFRAME_HPP

#include <algorithm>
#include <cstdint>
#include <cstring>
#include <string>
#include <utility>

#include "AEyeSensorAPI.h"

namespace aeye {

class HawkeyeFrame {
public:
  HawkeyeFrame() = default;
  HawkeyeFrame(std::string sensorIp, int frameId, BufferType bufType, uint16_t* buf, SweepInfo sweep_info, uint32_t sec = 0, uint32_t usec = 0) :
    frameId(frameId),
    sensorIp(std::move(sensorIp)),
    tsSec(sec),
    tsuSec(usec),
    bufferType(bufType),
    sweepInfo(sweep_info)
  {
    if (buf != nullptr){
      std::copy(buf, buf + HAWKEYE_BUF_LEN, buffer);
    }
  };
  int getFrameId() const { return frameId; }
  const std::string &getIpAddress() const { return sensorIp; }
  BufferType getBufferType() const { return bufferType; }
  SweepInfo getSweepInfo() const { return sweepInfo; }
  const uint16_t *getBuffer() const { return buffer; }
  void setFrameId(int value) { frameId = value; }
  void setIpAddress(const std::string &value) { sensorIp = value; }
  void setBufferType(BufferType value) { bufferType = value; }
  void setBuffer(uint16_t *value) { std::copy(value, value + HAWKEYE_BUF_LEN, buffer); }
  void setTime(uint32_t sec, uint32_t usec) {
    tsSec = sec;
    tsuSec = usec;
  }
private:
  int                  frameId{};
  std::string          sensorIp;
  uint32_t             tsSec{}; ///< Message timestamp seconds
  uint32_t             tsuSec{}; ///< Message timestamp microseconds
  BufferType           bufferType{};
  SweepInfo            sweepInfo{};
  uint16_t             buffer[HAWKEYE_BUF_LEN]{};
};
}
#endif //HAWKEYEFRAME_HPP
